import re

print("--------- 匹配开头和结尾 --------------")
print("--------- ^ 匹配开头 $ 匹配结尾 --------------")
print("--------- ^ 匹配开头 $ 匹配结尾 --------------")
res = re.match("^[a-zA-Z0-9]*$", "1a2b3c")
print(res.group())  # 1a2b3c

res = re.match("[^py]+", "xpython")  # 除了py之外的
print(res.group())  # x

res = re.match("[^py]+", "xxpython")
print(res.group())  # xx


res = re.match(".*e$", "leslie")  # 以 e 结尾的任意前缀字符
print(res.group())  # leslie
